﻿<%@ Page Title="Ngành" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="List.aspx.cs" Inherits="Dost.Khcn.Web.DanhMuc.LinhVuc.List" %>
<%@ Import Namespace="Resources" %>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    <div class="filtering">
        <%=GlobalStrings.Code %>:<input type="text" name="name" id="code" />
        <%=GlobalStrings.Name %>:<input type="text" name="name" id="name" />
        Lĩnh vực:<asp:DropDownList ID="ddlNhomLinhVucs" runat="server"></asp:DropDownList>
        <button type="submit" id="LoadRecordsButton"><%=GlobalStrings.LoadRecords %></button>
        <button type="submit" id="ResetButton"><%=GlobalStrings.Reset %></button>
    </div>
    <div id="ListContainer"></div>
    
    <script type="text/javascript">
        $(document).ready(function () {
            $('#ListContainer').jtable({
                title: 'Ngành',
                paging: true,
                pageSize: 10,
                sorting: true,
                defaultSorting: 'Id DESC',
                actions: {
                    listAction: 'List.aspx/LinhVucList',
                    createAction: 'List.aspx/Create',
                    updateAction: 'List.aspx/Update',
                    deleteAction: 'List.aspx/Delete'
                },
                fields: {
                    Id: {
                        title: "STT",
                        key: true,
                        create: false,
                        edit: false
                    },
                    Ma: {
                        title: '<%=GlobalStrings.Code %>',
                        width: '10%',
                        inputClass: 'validate[required] longname'
                    },
                    Ten: {
                        title: '<%=GlobalStrings.Name %>',
                        width: '30%',
                        inputClass: 'validate[required] longname'
                    },
                    NhomLinhVucId: {
                        title: 'Lĩnh vực',
                        width: '12%',
                        options: 'List.aspx/NhomLinhVucList'
                    },
                    Mota: {
                        title: '<%=GlobalStrings.Description %>',
                        width: '40%',
                        type: 'textarea',
                        sorting: false,
                        inputClass: 'longname'
                    }
                },

                //Initialize validation logic when a form is created
                formCreated: function (event, data) {
                    data.form.validationEngine();
                },
                //Validate form when it is being submitted
                formSubmitting: function (event, data) {
                    return data.form.validationEngine('validate');
                },
                //Dispose validation logic when form is closed
                formClosed: function (event, data) {
                    data.form.validationEngine('hide');
                    data.form.validationEngine('detach');
                }
            });

            //Re-load records when user click 'load records' button.
            $('#LoadRecordsButton').click(function(e) {
                e.preventDefault();
                $('#ListContainer').jtable('load', {
                    name: $('#name').val(),
                    nhomLinhVucId: $('#<%=ddlNhomLinhVucs.ClientID %>').val(),
                    code: $('#code').val()
                });
            });

            // Reset button
            $('#ResetButton').click(function (e) {
                e.preventDefault();
                $('#name').val('');
                $('#<%=ddlNhomLinhVucs.ClientID %>').val('0');
                $('#code').val('');
                $('#LoadRecordsButton').click();
            });

            //Load all records when page is first shown
            $('#LoadRecordsButton').click();
        });
    </script>
</asp:Content>
